/*
 *  $Id: Sorrow.cs 975 2009-12-16 17:13:22Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Affects {
    /// <summary>
    /// Эффект: скорбь (флаг)
    /// Уменьшает атаку на 1.
    /// </summary>
    public class Sorrow: FlagAffect {
        private static readonly Languages.Phrase NoSorrow = new Languages.Phrase("affect.sorrow.desc.ignore");
        private bool _active;

        public Sorrow() {
            _active = true;
        }

        public override string Id {
            get { return "sorrow"; }
        }

        public override Languages.Phrase Description {
            get { return _active ? base.Description : NoSorrow; }
        }

        public override ElementType Element {
            get { return ElementType.Light; }
        }

        public override AffectIcon Icon {
            get { return AffectIcon.Sorrow; }
        }

        public override void SetAffect() {
            base.SetAffect();
            _active = !LocalSummary.Flags[typeof(SorrowIgnore)];
            UpdateDescription();
            if (_active) LocalSummary.ChangeDamage(-1);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            if (_active) LocalSummary.ChangeDamage(1);
        }

        public void Update() {
            ResetAffect();
            SetAffect();
        }
    }

    /// <summary>
    /// Эффект: игнорирование скорби
    /// Существо с этим эффектом не понижает атаку от скорби.
    /// </summary>
    public class SorrowIgnore: FlagAffect {
        public SorrowIgnore() {}

        public override string Id {
            get { return "sorrow.ignore"; }
        }

        public override AffectIcon Icon {
            get { return AffectIcon.SorrowIgnore; }
        }

        public override ElementType Element {
            get { return ElementType.Light; }
        }

        public override void SetAffect() {
            base.SetAffect();
            Update();
        }
        public override void ResetAffect() {
            base.ResetAffect();
            Update();
        }

        public void Update() {
            Sorrow affect = Owner.GetAffect<Sorrow>();
            if (affect != null) affect.Update();
        }
    }
}